<template>
  <div class="banner">
    <el-carousel :height="bannerHeight" :interval="5000" arrow="always">
      <el-carousel-item v-for="item in bannerList" :key="item.id">
        <div class="banner-item" :style="{ backgroundImage: `url(${item.imageUrl})` }">
          <div class="banner-content">
            <h2 class="banner-title">{{ item.title }}</h2>
            <p class="banner-description">{{ item.description }}</p>
            <el-button v-if="item.buttonText" type="primary" size="large" @click="handleClick(item)">
              {{ item.buttonText }}
            </el-button>
          </div>
        </div>
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
import { defineComponent, ref } from 'vue';

export default defineComponent({
  name: 'Banner',
  setup() {
    const bannerHeight = '600px';
    const bannerList = ref([
      {
        id: 1,
        imageUrl: '/images/banner1.jpg',
        title: '版权保护从这里开始',
        description: '为您的创作保驾护航，让每一份创意都得到应有的尊重',
        buttonText: '立即体验',
        link: '/copyright/evidence'
      },
      {
        id: 2,
        imageUrl: '/images/banner2.jpg',
        title: '一站式版权服务平台',
        description: '提供版权存证、登记、监测、维权等全方位服务',
        buttonText: '了解更多',
        link: '/about/intro'
      }
    ]);

    const handleClick = (item) => {
      if (item.link) {
        window.location.href = item.link;
      }
    };

    return {
      bannerHeight,
      bannerList,
      handleClick
    };
  }
});
</script>

<style lang="scss">
.banner {
  @include flex(column, center, center);
  height: 600px;
  background-position: center;
  background-size: cover;
  
  &-title {
    @include text-truncate(2);
    font-size: $font-size-extra-large;
    color: $background-color-white;
  }
  
  &-item {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    position: relative;

    &::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.3);
    }
  }

  &-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #fff;
    width: 80%;
    max-width: 800px;
    z-index: 1;
  }

  &-title {
    font-size: 48px;
    font-weight: bold;
    margin-bottom: 20px;
    line-height: 1.2;
  }

  &-description {
    font-size: 24px;
    margin-bottom: 30px;
    line-height: 1.5;
  }

  :deep(.el-carousel__arrow) {
    background-color: rgba(0, 0, 0, 0.3);
    font-size: 20px;
    width: 50px;
    height: 50px;

    &:hover {
      background-color: rgba(0, 0, 0, 0.5);
    }
  }

  :deep(.el-carousel__indicators) {
    bottom: 30px;
  }

  :deep(.el-carousel__button) {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.6);

    &:hover {
      background-color: #fff;
    }
  }

  @media screen and (max-width: 768px) {
    &-title {
      font-size: 32px;
    }

    &-description {
      font-size: 18px;
    }
  }
}
</style>
  